import { computed, Ref, watch } from 'vue'
import { useRoute } from 'vue-router'

export function useQrcode({ modelType }: { modelType: Ref<string> }) {
  const route = useRoute()
  const isCode = computed(() => route.query.type === 'code')

  watch(
    isCode,
    (isCode) => {
      if (isCode) {
        modelType.value = '7'
      }
    },
    { immediate: true }
  )

  return {
    isCode,
  }
}
